import { Data } from "./interface";
/*
 * @Author: Tianjian Wei z5492347@ad.unsw.edu.au
 * @Date: 2024-02-29 22:48:29
 * @LastEditors: Tianjian Wei z5492347@ad.unsw.edu.au
 * @LastEditTime: 2024-03-01 21:02:51
 * @FilePath: /comp1531/project-backend/src/dataStore.js
 */
// YOU SHOULD MODIFY THIS OBJECT BELOW ONLY
let data: Data = {
    users: [
        {
            userID: 1,
            QuizID: [1, 2, 3],
            FirstName: 'Sean',
            LastName: 'Yu',
            email: 'yujixiao000@qq.com',
            password: '123456',
            usedPasswords: ['123456'],
            numSuccessfulLogins: 114,
            numFailedPasswordsSinceLastLogin: 514,
        },
        {
            userID: 5546,
            QuizID: [1, 2, 3],
            FirstName: 'Sean',
            LastName: 'Yu',
            email: 'yujixiao000@qq.com',
            password: '123456',
            usedPasswords: ['123456'],
            numSuccessfulLogins: 114,
            numFailedPasswordsSinceLastLogin: 514,
        },
        {
            userID: 5545,
            QuizID: [1, 2, 3],
            FirstName: 'Sean',
            LastName: 'Yu',
            email: 'yujixiao000@qq.com',
            password: '123456',
            usedPasswords: ['123456'],
            numSuccessfulLogins: 114,
            numFailedPasswordsSinceLastLogin: 514,
        }
    ],
    quizzes: [
        {
            QuizID: 1,
            AuthorID: [11],
            Name: 'C_pointer',
            TimeCreated: new Date('06-06-2019'),
            TimeLastEdited: new Date('01-02-2024'),
            Description: 'This is a very hard quiz',
            State: 'ACTIVE',
            Questions: [
                {
                    question: "Who is the Monarch of England?",
                    questionId: 5546,
                    duration: 4,
                    points: 5,
                    answers: [
                        {
                            answer: "Prince Charles",
                            correct: true
                        }
                    ]
                },
                {
                    question: "Who is a?",
                    questionId: 3,
                    duration: 3,
                    points: 4,
                    answers: [
                        {
                            answer: "c",
                            correct: true
                        }
                    ]
                }
            ],
            Sessions: [
                {
                    Messages: [],
                    QuizID: 5546,
                    SessionID: 234234,
                    State: 'QUESTION_OPEN',
                    StartTime: new Date('2024-01-01T10:00:00Z'),
                    Results: [
                        { playerId: 5547, score: 85 , State :"QUESTION_OPEN" },
                        { playerId: 5050, score: 90, State:"QUESTION_OPEN" },
                        { playerId: 5545, score: 90, State:undefined }
                    ],
                    players: [
                        { playerId: 1, name: 'Player 1', sessionId: 101, score: 100 },
                    ]
                },
                {
                    Messages: [],
                    QuizID: 5547,
                    SessionID: 234234,
                    State: 'FINAL_RESULTS',
                    StartTime: new Date('2024-01-01T10:00:00Z'),
                    Results: [
                        { playerId: 5546, score: 90, State:"FINAL_RESULTS" }
                    ],
                    players: [
                        { playerId: 1, name: 'Player 1', sessionId: 101, score: 100 },
                    ]
                },

                {
                    Messages: [],
                    QuizID: 5548,
                    SessionID: 102,
                    State: 'ANSWER_SHOW',
                    StartTime: new Date('2024-01-02T10:00:00Z'),
                    EndTime: new Date('2024-01-02T11:00:00Z'),
                    Results: [
                        { playerId: 3, score: 75,State :undefined },
                        { playerId: 5548, score: 80 ,State :"ANSWER_SHOW"}
                    ],
                    players: [
                        { playerId: 1, name: 'Player 1', sessionId: 101, score: 100 },
                    ]
                }
            ],
            timeLastEdited: undefined
        }, {
            QuizID: 5546,
            AuthorID: [11],
            Name: 'C_pointer',
            TimeCreated: new Date('06-06-2019'),
            TimeLastEdited: new Date('01-02-2024'),
            Description: 'This is a very hard quiz',
            State: 'ACTIVE',
            Questions: [
                {
                    question: "Who is the Monarch of England?",
                    questionId: 5,
                    duration: 4,
                    points: 5,
                    answers: [
                        {
                            answer: "Prince Charles",
                            correct: true
                        }
                    ]
                },
                {
                    question: "Who is a?",
                    questionId: 3,
                    duration: 3,
                    points: 4,
                    answers: [
                        {
                            answer: "c",
                            correct: true
                        }
                    ]
                }
            ],
            Sessions: [
            ],
            timeLastEdited: undefined
        }
    ],
    sessions: [
        {
            Messages: [],
            QuizID: 1,
            SessionID: 101,
            State: 'ACTIVE',
            StartTime: new Date('2024-01-01T10:00:00Z'),
            Results: [
                { playerId: 1, score: 85 ,State :undefined},
                { playerId: 2, score: 90,State :undefined }
            ],
            players: [
                { playerId: 1, name: 'Player 1', sessionId: 101, score: 100 },
            ]
        },

        {
            Messages: [],
            QuizID: 5546,
            SessionID: 102,
            State: 'END',
            StartTime: new Date('2024-01-02T10:00:00Z'),
            EndTime: new Date('2024-01-02T11:00:00Z'),
            Results: [
                { playerId: 3, score: 75 ,State :undefined},
                { playerId: 4, score: 80 ,State :undefined}
            ],
            players: [
                { playerId: 1, name: 'Player 1', sessionId: 101, score: 100 },
            ]
        }
    ],
    players: [
    ],
    Tokens: {}
};




// YOU SHOULD MODIFY THIS OBJECT ABOVE ONLY

// YOU SHOULDNT NEED TO MODIFY THE FUNCTIONS BELOW IN ITERATION 1

/*
Example usage
    let store = getData()
    console.log(store) # Prints { 'names': ['Hayden', 'Tam', 'Rani', 'Giuliana', 'Rando'] }

    names = store.names

    names.pop()
    names.push('Jake')

    console.log(store) # Prints { 'names': ['Hayden', 'Tam', 'Rani', 'Giuliana', 'Jake'] }
    setData(store)
*/

// Use get() to access the data
function getData() {
    return data;
}

// Use set(newData) to pass in the entire data object, with modifications made
function setData(newData: Data) {
    data = newData;
}

export { data, getData, setData };
